home *** CD-ROM | disk | FTP | other *** search
/ Enter 2002 August / EnterCD 8_2002.iso / Internet / Adobe GoLive 6.0 / data1.cab / PF_AppDir_Mod_ExtendScripts_WMLExt / parse.js < prev   
Encoding:
JavaScript  |  2002-03-28  |  9.9 KB  |  344 lines

  1. //------------------------------------------------------------------------------
  2. //
  3. // ADOBE SYSTEMS INCORPORATED
  4. // Copyright 2000-2002 Adobe Systems Incorporated 
  5. // All Rights Reserved
  6. //
  7. // NOTICE: Adobe permits you to use, modify, and distribute 
  8. // this file in accordance with the terms of the Adobe license 
  9. // agreement accompanying it. If you have received this file 
  10. // from a source other than Adobe, then your use, modification, 
  11. // or distribution of it requires the prior written permission 
  12. // of Adobe.
  13. //
  14. //------------------------------------------------------------------------------
  15.  
  16.  
  17. //----------------------------------------------------
  18. // parse functions:
  19. //
  20. // Description:
  21. //   Called by parseBox() for each custom box.
  22. //   Display error message if box inserted in 
  23. //   incorrect location.
  24. //  Set and create links on the box.
  25.  
  26. function parseA(box, reason)
  27. {        
  28.     if (!document) {
  29.         // there should always be a document
  30.         // since the custom box is drawn in a document
  31.         return;
  32.     }
  33.     var version = getWMLVersion(document);
  34.         
  35.     box.ctlAhref = (box.element.href) ?
  36.         box.createLink (box.element.href) :
  37.         box.createLink (settings.masterPrefs.emptyReferenceName);        
  38.     if (checkPositionForAnchorAndA(box.element, version) < 0) {
  39.         if (version == "1.1") {
  40.             alert(module.localize("A must be inside Fieldset, P, Strong, Em, B, I, or U."));    
  41.         }
  42.         else    {
  43.             alert(module.localize("A must be inside Fieldset, P, Pre, Strong, Em, B, I, or U."));    
  44.         }
  45.     }                
  46. }
  47.  
  48. function parseAnchor(box, reason)
  49. {
  50.     if (!document) {
  51.         // there should always be a document
  52.         // since the custom box is drawn in a document
  53.         return;
  54.     }
  55.     var version = getWMLVersion(document);
  56.     
  57.     if (checkPositionForAnchorAndA(box.element, version) < 0) {
  58.         if (version == "1.1") {
  59.             alert(module.localize("Anchor must be inside Fieldset, P, Strong, Em, B, I, or U."));
  60.         }        
  61.         else {
  62.             alert(module.localize("Anchor must be inside Fieldset, P, Pre, Strong, Em, B, I, or U."));
  63.         }    
  64.     }
  65. }
  66.  
  67. function parseCard(box,reason)
  68. {
  69.     box.onenterforward = (box.element.onenterforward) ? 
  70.             box.createLink(box.element.onenterforward) :    
  71.             box.createLink(settings.masterPrefs.emptyReferenceName);
  72.     box.onenterbackward = (box.element.onenterbackward) ?
  73.              box.createLink (box.element.onenterbackward) :
  74.              box.createLink(settings.masterPrefs.emptyReferenceName);
  75.     box.ontimer = (box.element.ontimer) ?
  76.             box.createLink (box.element.ontimer) :
  77.             box.createLink(settings.masterPrefs.emptyReferenceName);
  78.     // fill in id attribute if undefined
  79.     if (box.element.id == undefined) {
  80.         box.element.setAttribute("id", "C" + Math.random().toString().substring(2));
  81.     }
  82.     //check to see if the box is attached to the correct
  83.     //parent element only on drag and drop 
  84.     if (reason == 2 || reason == 3){                                        
  85.         var errVal = checkPositionForCard(box.element);
  86.         if (errVal == c_parentWrong) {
  87.             alert (module.localize("Card must be inside the WML deck."));    
  88.         }        
  89.         else if (errVal == c_previousWrong) {
  90.             alert(module.localize("Card inserted in wrong position."));        
  91.         }                    
  92.     }            
  93. }
  94.  
  95. function parseDo(box, reason)
  96. {
  97.     if (!document) {
  98.         // there should always be a document
  99.         // since the custom box is drawn in a document
  100.         return;
  101.     }
  102.     var version = getWMLVersion(document);
  103.     
  104.     if (reason == 2 || reason == 3) {                
  105.         if (checkPositionForDo(box.element, version) < 0) {
  106.             if (version == "1.1") {
  107.                 alert(module.localize("Do must be inside Card, Fieldset, P, or Template."));    
  108.             }        
  109.             else    {
  110.                 alert(module.localize("Do must be inside Card, Fieldset, P, Pre, or Template."));    
  111.             }    
  112.         }
  113.     }    
  114. }
  115.  
  116. function parseFieldset(box, reason)
  117. {                
  118.     if (reason == 2 || reason == 3){
  119.         if (checkPositionForFieldset(box.element) < 0) {
  120.             alert(module.localize("Fieldset must be inside Fieldset or P."));        
  121.         }        
  122.     }
  123. }
  124.  
  125. function parseGo(box, reason)
  126. {
  127.     box.ctlGoHref = (box.element.href) ?
  128.         box.createLink (box.element.href) :
  129.         box.createLink(settings.masterPrefs.emptyReferenceName);
  130.     if (reason == 2 || reason == 3) {
  131.         var errVal = checkPositionForGoPrevAndRefresh(box.element);
  132.         if (errVal == c_parentWrong) {
  133.             alert(module.localize("Go must be inside Do, Onevent or Anchor."));        
  134.         }
  135.         else if (errVal < 0) {
  136.             alert(module.localize("Go inserted in wrong position."));    
  137.         }            
  138.     }
  139. }
  140.  
  141. function parseImg(box, reason)
  142. {        
  143.     box.ctlImgsrc = (box.element.src) ?
  144.         box.createLink (box.element.src) :
  145.         box.createLink (settings.masterPrefs.emptyReferenceName);
  146.     if (reason == 2 || reason == 3){
  147.         if (checkPositionForImg(box.element) < 0) {
  148.             alert(module.localize("Image must be inside Fieldset, A, Anchor, P, Em, Strong, B, I, or U."));        
  149.         }
  150.     }
  151. }
  152.  
  153. function parseInput(box, reason)
  154. {    
  155.     if (!document) {
  156.         // there should always be a document
  157.         // since the custom box is drawn in a document
  158.         return;
  159.     }
  160.     var version = getWMLVersion(document);
  161.     
  162.     if (reason == 2 || reason == 3){
  163.         var errVal = checkPositionForInputAndSelect(box.element, version);
  164.         if (errVal == c_parentWrong) {
  165.             if (version == "1.1") {
  166.                 alert(module.localize("Input must be inside Fieldset, or P."));    
  167.             }    
  168.             else {
  169.                 alert(module.localize("Input must be inside Fieldset, P, or Pre."));        
  170.             }
  171.         }
  172.         else if (errVal < 0) { // should not happen
  173.             alert(module.localize("Input inserted in wrong position."));            
  174.         }        
  175.     }
  176. }
  177.  
  178. function parseNoop(box, reason)
  179. {
  180.     if (reason == 2 || reason == 3) {
  181.         var errVal = checkPositionForNoop(box.element);
  182.         if (errVal == c_parentWrong) {
  183.             alert(module.localize("Noop must be inside Do or Onevent."));    
  184.         }
  185.         else if (errVal < 0) {
  186.             alert(module.localize("Noop inserted in wrong position."));    
  187.         }
  188.     }
  189. }
  190.  
  191. function parseOnevent(box, reason)
  192. {
  193.     if (reason == 2 || reason == 3) {        
  194.         var errVal = checkPositionForOnevent(box.element);
  195.         if (errVal == c_parentWrong) {
  196.             alert(module.localize("Onevent must be inside Card, Template or Option."));    
  197.         }
  198.         else if (errVal < 0) {
  199.             alert(module.localize("Onevent inserted in wrong position."));
  200.         }
  201.     }
  202. }
  203.  
  204.             
  205. function parseOption(box, reason)
  206. {                
  207.     if (reason == 2 || reason == 3) {
  208.         if (checkPositionForOption(box.element) < 0) {
  209.             alert(module.localize("Option must be inside Select or Optgroup."));    
  210.         }
  211.     }            
  212. }
  213.  
  214. function parseOptiongroup(box, reason)
  215. {                
  216.     if (reason == 2 || reason == 3){
  217.         if (checkPositionForOptgroup(box.element) < 0) {
  218.             alert(module.localize("Optgroup must be inside Select."));        
  219.         }
  220.     }
  221. }
  222.             
  223. function parsePostfield(box, reason)
  224. {
  225.     if (reason == 2 || reason == 3) {
  226.         if (checkPositionForPostfield(box.element) < 0) {
  227.             alert(module.localize("Postfield must be inside Go."));    
  228.         }
  229.     }
  230. }
  231.  
  232. function parsePre(box, reason)
  233. {
  234.     if (!document) {
  235.         // there should always be a document
  236.         // since the custom box is drawn in a document
  237.         return;
  238.     }
  239.     var version = getWMLVersion(document);
  240.  
  241.     if (reason == 2 || reason == 3) {
  242.         var errVal = checkPositionForPre(box.element, version);
  243.         if (errVal == c_versionWrong) {
  244.             alert(module.localize("Pre not allowed in WML 1.1 document."));
  245.         }
  246.         else if (errVal == c_parentWrong) {
  247.             alert(module.localize("Pre must be inside Card."));    
  248.         }    
  249.         else if (errVal < 0) {
  250.             alert(module.localize("Pre inserted in wrong position."));    
  251.         }        
  252.     }
  253. }
  254.  
  255. function parsePrev(box, reason)
  256. {
  257.     if (reason == 2 || reason == 3) {
  258.         var errVal = checkPositionForGoPrevAndRefresh(box.element);
  259.         if (errVal == c_parentWrong) {
  260.             alert(module.localize("Prev must be inside Do, Onevent or Anchor."));        
  261.         }
  262.         else if (errVal < 0) {
  263.             alert(module.localize("Prev inserted in wrong position."));        
  264.         }                                    
  265.     }
  266. }
  267.  
  268. function parseRefresh(box, reason)
  269. {
  270.     if (reason == 2 || reason == 3) {    
  271.         var errVal = checkPositionForGoPrevAndRefresh(box.element);
  272.         if (errVal == c_parentWrong) {
  273.             alert(module.localize("Refresh must be inside Do, Onevent or Anchor."));        
  274.         }
  275.         else if (errVal < 0) {
  276.             alert(module.localize("Refresh inserted in wrong position."));    
  277.         }                                                
  278.     }
  279. }
  280.  
  281. function parseSelect(box, reason)
  282. {
  283.     if (!document) {
  284.         // there should always be a document
  285.         // since the custom box is drawn in a document
  286.         return;
  287.     }
  288.     var version = getWMLVersion(document);
  289.     
  290.      if (reason == 2 || reason == 3) {
  291.          if (checkPositionForInputAndSelect(box.element, version) < 0) {
  292.              if (version == "1.1") {
  293.                  alert(module.localize("Select must be inside Fieldset, or P."));    
  294.              }
  295.              else {
  296.                  alert(module.localize("Select must be inside Fieldset, P, or Pre."));    
  297.              }
  298.          }
  299.      }    
  300. }
  301.             
  302. function parseSetvar(box, reason)
  303. {
  304.     if (reason == 2 || reason == 3) {
  305.         if (checkPositionForSetvar(box.element) < 0) {
  306.             alert(module.localize("Setvar must be inside Go, Prev, or Refresh."));    
  307.         }    
  308.     }
  309. }
  310.  
  311. function parseTemplate(box, reason){            
  312.     box.ctlTemplateOnEnterForward = (box.element.onenterforward) ?
  313.             box.createLink (box.element.onenterforward) :
  314.             box.createLink (settings.masterPrefs.emptyReferenceName);
  315.     box.ctlTemplateOnEnterBackward = (box.element.onenterbackward) ?
  316.             box.createLink (box.element.onenterbackward) :
  317.             box.createLink (settings.masterPrefs.emptyReferenceName);
  318.     box.ctlTemplateOnTimer = (box.element.ontimer) ?
  319.             box.createLink (box.element.ontimer) :
  320.             box.createLink (settings.masterPrefs.emptyReferenceName);
  321.                 
  322.     if (reason == 2 || reason == 3) {                                            
  323.         var i = checkPositionForTemplate(box.element);
  324.         if (i == c_parentWrong) {
  325.             alert (module.localize("Template must be inside the WML deck."));    
  326.         }
  327.         else if (i == c_previousWrong) {
  328.             alert(module.localize("Template must be first in the WML deck."));
  329.         }
  330.     }                                        
  331. }
  332.  
  333. function parseTimer(box, reason)
  334. {                
  335.     if (reason == 2 || reason == 3){
  336.         var errVal = checkPositionForTimer(box.element);
  337.         if (errVal == c_parentWrong) {
  338.             alert(module.localize("Timer must be inside Card."));    
  339.         }
  340.         else if (errVal < 0) {
  341.             alert(module.localize("Timer inserted in wrong position."));
  342.         }
  343.     }
  344. }